# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=android-tools
pkgver=35.0.2
pkgrel=1
pkgdesc="Android platform tools"
url="https://sites.google.com/a/android.com/tools/"
# s390x, ppc64le: Unsupported by vendored BoringSSL
arch="all !s390x !ppc64le !loongarch64"
license="Apache-2.0 MIT"
options="!check" # upstream doesn't have a test suite
depends="python3"
makedepends="pcre2-dev linux-headers gtest-dev go perl cmake protobuf-dev
	brotli-dev zstd-dev lz4-dev samurai abseil-cpp-dev fmt-dev"
subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch"
source="https://github.com/nmeum/android-tools/releases/download/$pkgver/android-tools-$pkgver.tar.xz
	0001-Fix-libusb-enumeration.patch"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

bashcomp() {
	default_bashcomp
	amove usr/share/android-tools/completions
}

sha512sums="
391ce4d638b274d7bbae24a3df8de8b5812a982570f29b2aef37d12a3ba7ed6f66b5c0b7f908759e0b0da30d152b5319af0fef16c54bdc3b9f4074fb22f80d10  android-tools-35.0.2.tar.xz
941dddf82725b1f44d158e4ce361355004a63292f72f91e2008436bd687cf55e09cef12875f94057702d056e35cc0ba1df13432caefee7d37d039aa1fd31c65e  0001-Fix-libusb-enumeration.patch
"
